// 笔试强训day29:排序子序列

#include <iostream>
#include <vector>
using namespace std;

int main() {
    int n = 0; cin >> n;
    int pprev = 0, prev = 0, cur = 0, ans = 0;
    vector<int> a(n + 1, 0);
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++)
    {
        if(a[i] < a[i + 1])
        {
            while(i < n && a[i] <= a[i + 1])
            {
                i++;
            }
            ans++;
        }
        else if(a[i] > a[i + 1])
        {
            while(i < n && a[i] >= a[i + 1])
            {
                i++;
            }
            ans++;
        }
    }
    cout << ans << endl;
}